From 86cd882200f54655c553c40341cd8ab3ecf378ad Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 15 Apr 2010 11:33:39 +0100 Subject: [PATCH] Update comments around spin_trylock() usage for sysctl and xenpf locks. Since the execution of stop_machine_run() via cpu_down() is now always deferred to a hypercall continuation context, the above locks are not held at that time. Hence the trylock is not specifically to avoid deadlock with stop_machine_run(), but rather a more general paranoia about deadlocks in general. Signed-off-by: Keir Fraser --- xen/arch/x86/platform_hypercall.c | 6 +++++- xen/common/sysctl.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c index dc2214930a..26883b4d1c 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -73,7 +73,11 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) if ( op->interface_version != XENPF_INTERFACE_VERSION ) return -EACCES; - /* spin_trylock() avoids deadlock with stop_machine_run(). */ + /* + * Trylock here avoids deadlock with an existing platform critical section + * which might (for some current or future reason) want to synchronise + * with this vcpu. + */ while ( !spin_trylock(&xenpf_lock) ) if ( hypercall_preempt_check() ) return hypercall_create_continuation( diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index ba16353266..db27fc233c 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -48,7 +48,11 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) if ( op->interface_version != XEN_SYSCTL_INTERFACE_VERSION ) return -EACCES; - /* spin_trylock() avoids deadlock with stop_machine_run(). */ + /* + * Trylock here avoids deadlock with an existing sysctl critical section + * which might (for some current or future reason) want to synchronise + * with this vcpu. + */ while ( !spin_trylock(&sysctl_lock) ) if ( hypercall_preempt_check() ) return hypercall_create_continuation( -- 2.30.2